package com.tarena.lbs.basic.web.controller;

import com.tarena.lbs.base.protocol.model.Result;
import com.tarena.lbs.base.protocol.pager.PageResult;
import com.tarena.lbs.basic.web.service.IStoreChainService;
import com.tarena.lbs.common.basic.converter.StoreChainConverter;
import com.tarena.lbs.pojo.basic.query.StoreChainQuery;
import com.tarena.lbs.pojo.basic.vo.StoreChainVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@Api(tags = "二维码管理")
public class StoreChainController {

    @Autowired
    private IStoreChainService storeChainService;

    @Autowired
    private StoreChainConverter storeChainConverter;


    @PostMapping("/admin/basic/chain/getAll")
    @ApiOperation("获取二维码列表-分页")
    public Result<PageResult<StoreChainVO>> getAll(@RequestBody StoreChainQuery storeChainQuery) {
        PageResult<StoreChainVO> storeChainVOPaginationResult = storeChainService.getAll(storeChainQuery);
        return new Result<>(storeChainVOPaginationResult);
    }

    @PutMapping("/admin/basic/chain/enable/{id}")
    @ApiOperation("修改门店二维码状态-启用")
    @ApiImplicitParams(
            @ApiImplicitParam(value = "二维码ID", name = "id", example = "1", required = true))
    public Result enableStatus(@PathVariable Integer id) {
        storeChainService.enableStatusById(id);
        return new Result<>("二维码启用完成!");
    }

    @PutMapping("/admin/basic/chain/disable/{id}")
    @ApiOperation("修改门店二维码状态-禁用")
    @ApiImplicitParams(
            @ApiImplicitParam(value = "二维码ID", name = "id", example = "1", required = true))
    public Result disableStatus(@PathVariable Integer id) {
        storeChainService.disableStatusById(id);
        return new Result<>("二维码禁用完成!");
    }


}
